# -*- coding: utf-8 -*-

from functools import wraps
import time
import logging

logger = logging.getLogger(__name__)


def timer(func):
    """统计函数执行时间"""

    @wraps(func)
    def wrapper(*args, **kwargs):
        init_time = time.time()
        func(*args, **kwargs)
        logger.info('run [%s] time:%fs' % (func.__name__, time.time() - init_time))

    return wrapper
